<?php

namespace apiend\modules\setting\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\setting\models\MapLinkSearch;
use apiend\modules\setting\models\FreightDashboardLogic;
use apiend\modules\setting\models\StoreExpress;
use apiend\modules\setting\models\StoreExpressForm;

/**
 * 节假日更新
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class HolidayController extends Controller {

    /**
     * 商城链接列表
     * @inheritdoc
     */
    public function actionIndex() {
        $model = new FreightDashboardLogic();
        $model->store_id = $this->storeId;
        return $model->toArray();
    }

    /**
     * 商城链接列表
     * @inheritdoc
     */
    public function actionAddress() {
        return MapLinkSearch::findByGroupName('SourceLink');
    }

    /**
     * 商城链接列表
     * @inheritdoc
     */
    public function actionExpress() {
        $model = new StoreExpressForm();
        $model->store_id = $this->storeId;
        if (!$model->load(Yii::$app->request->post(), '')) {
            return $model->dumpError('设置添加失败');
        }
        return $model->save();
    }

    /**
     * 商城链接列表
     * @inheritdoc
     */
    public function actionLogicstics() {
        $model = new StoreExpress();
        $model::$storeId = $this->storeId;
        return $model->find()->all();
    }

}
